
#include <bitset>
#include "clock.h"

void Clock::reset_clock() {
  dut->rstn = 0;
  dut->set_time = 0;
  dut->set_alarm = 0;
  dut->set_hour = 0;
  dut->set_min = 0;
  dut->toggle = 0;
}

void Clock::dereset_clock() {
  dut->rstn = 1;
  dut->toggle = 1;
}

void Clock::show_clock() {
  printf("time: %2x : %2x : %2x\n", dut->t_hour, dut->t_min, dut->t_sec);
}

void Clock::show_alarm() {
  printf("alarm: %2x : %2x\n", dut->a_hour, dut->a_min);
}

void Clock::set_time_hour(uint64_t b) {
  dut->set_time = b;
  dut->set_hour = b;
}

void Clock::set_time_min(uint64_t b) {
  dut->set_time = b;
  dut->set_min = b;
}

void Clock::set_alarm_hour(uint64_t b) {
  dut->set_alarm = b;
  dut->set_hour = b;
}

void Clock::set_alarm_min(uint64_t b) {
  dut->set_alarm = b;
  dut->set_min = b;
}

void Clock::set_toggle(uint64_t n) {
  dut->toggle = n;
}

void Clock::display() {
  std::cout << "display:" << '\t' << std::bitset<16>(uint(dut->hour)) << std::endl;
  std::cout << "display:" << '\t' << std::bitset<16>(uint(dut->min)) << std::endl;
  std::cout << "display:" << '\t' << std::bitset<16>(uint(dut->sec)) << std::endl;
}

void Clock::pos_edge() {
  dut->sys_clk = 1;
  dut->eval();
}

void Clock::neg_edge() {
  dut->sys_clk = 0;
  dut->eval();
}

